﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KALE_Scanning
{
    public partial class frmPDFValues : Form
    {
        public frmPDFValues()
        {
            InitializeComponent();
        }

        private void btnClosePDFValues_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void btnClearPDFValues_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Girilmiş olan pdf değerleri silinecek. Devam edilsin mi ?", "Uyarı", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
            {
                txtKeywords.Text = "";
                txtSubject.Text = "";
                txtTitle.Text = "";
                UserProperty.ClearPDFValues();
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                txtTitle.Focus();
            }
        }

        private void btnSavePDFValues_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrEmpty(txtTitle.Text) & string.IsNullOrEmpty(txtSubject.Text) & string.IsNullOrEmpty(txtKeywords.Text))
            {
                MessageBox.Show("Tüm PDF değerleri boş olduğundan kaydetme işlemi yapılamaz. Formu kapatmak için 'İptal' butonunu kullanın!", "Dikkat", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                btnClosePDFValues.Focus();
            }
            if (!string.IsNullOrEmpty(txtTitle.Text) || !string.IsNullOrEmpty(txtSubject.Text) || !string.IsNullOrEmpty(txtKeywords.Text))
            {
                UserProperty.SetPDFValues(txtTitle.Text.Trim(), txtSubject.Text.Trim(), txtKeywords.Text.Trim());
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }

        private void frmPDFValues_Load(object sender, EventArgs e)
        {
            if (UserProperty.PDFValue.IsClear == false)
            {
                this.txtKeywords.Text = UserProperty.PDFValue.Keywords;
                this.txtSubject.Text = UserProperty.PDFValue.Subject;
                this.txtTitle.Text = UserProperty.PDFValue.Title;
            }
        }
    }
}
